package cn.g31010.sip.model
{
	import cn.g31010.sip.view.VideoPanel;
	import cn.g31010.sip.vo.Music;
	
	import com.adobe.cairngorm.model.ModelLocator;
	
	import flash.media.*;
	
	import mx.collections.ArrayCollection;
	
	public class MusicModel implements ModelLocator
	{
		private static var modelLocator : MusicModel;
		[Bindable]
		public var musics:ArrayCollection=new ArrayCollection();
		public static function getInstance() : MusicModel 
		{
			if ( modelLocator == null ){
				modelLocator = new MusicModel();
			}
			return modelLocator;
	   }
	   
   		public function MusicModel() 
   		{
   			if ( MusicModel.modelLocator != null )
				throw new Error( "Only one ModelLocator instance should be instantiated" );	
			
   		}
   		
   		public function addMusic(music:Music):void{
   			musics.addItem(music);
   		}
   		
   		public function removeMusic(id:String):Music{
   			for(var i:int=0;i<musics.length;i++){
   				var v:Music=musics[i] as Music;
   				if(v.id==id){
   					musics.removeItemAt(i);
   					return v;
   				}
   			}
   			return null;
   		}
	}
}